package com.vectortest.vector;

import android.graphics.drawable.AnimatedVectorDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

    private ImageView mImageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mImageView = (ImageView)findViewById(R.id.imageview);
        findViewById(R.id.btnStart).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AnimatedVectorDrawable animatedVectorDrawable =
                        (AnimatedVectorDrawable) mImageView.getDrawable();
                if(animatedVectorDrawable.isRunning()) {
                    animatedVectorDrawable.stop();
                } else {
                    animatedVectorDrawable.start();
                }
            }
        });
    }
}
